//
//  AddPartnerViewController.m
//  beautyLamp
//
//  Created by Tam Kwok To Michael on 2017/8/22.
//  Copyright © 2017年 Tam Kwok To Michael. All rights reserved.
//

#import "AddPartnerViewController.h"
#import "SearchPartnerTableViewController.h"
#import "BLHeader.h"

@interface AddPartnerViewController () <UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) UISearchController *searchController;
@property (nonatomic, strong) SearchPartnerTableViewController *searchVC;

@end

@implementation AddPartnerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}

- (UISearchController *)searchController {
    if(_searchController == nil) {
        _searchController = [[UISearchController alloc] initWithSearchResultsController:self.searchVC];
        _searchController.searchResultsUpdater = self.searchVC;
        self.searchVC.searchController = _searchController;
        self.searchVC.navigation = self.navigationController;
        [_searchController.searchBar setPlaceholder:@"搜索"];
        [_searchController.searchBar setBarTintColor:DEFAULT_SEARCHBAR_COLOR];
        [_searchController.searchBar sizeToFit];
        [_searchController.searchBar setDelegate:self.searchVC];
        [_searchController.searchBar.layer setBorderWidth:0.5f];
        [_searchController.searchBar.layer setBorderColor:WBColor(220, 220, 220, 1.0).CGColor];
        // _searchController.dimsBackgroundDuringPresentation = NO;
        _searchController.hidesNavigationBarDuringPresentation = YES;
    }
    return _searchController;
}

- (SearchPartnerTableViewController *)searchVC {
    if(_searchVC == nil) {
        _searchVC = [[SearchPartnerTableViewController alloc] init];
        [self addChildViewController:self.searchVC];
    }
    return _searchVC;
}

- (void)setupUI {
    NSString *userClass = [[NSUserDefaults standardUserDefaults] objectForKey:USERCLASS];
    self.title = [userClass integerValue] == 1 ? @"添加销售" : @"添加店主";
    self.tableView.tableHeaderView = self.searchController.searchBar;
    self.tableView.tableFooterView = [UIView new];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    return nil;
}

@end
